<%@ taglib prefix="c" uri="jakarta.tags.core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <base href="<%=request.getContextPath()%>/">
  <meta charset="UTF-8">
  <title>新增医院</title>
  <link rel="stylesheet" href="statics/css/hisStyle.css">
  <link rel="stylesheet" href="statics/css/common-styles.css">
</head>
<body>
<%@include file="../common/sidebar.jsp"%>
<div class="main-content">
  <%@include file="../common/top.jsp"%>
  <div class="content">
    <div class="function-page">
      <!-- 页面标题 -->
      <div class="page-header">
        <h1>新增医院</h1>
      </div>

      <!-- 错误提示 -->
      <c:if test="${not empty sessionScope.error}">
        <div class="message-error">
            ${sessionScope.error}
            <% session.removeAttribute("error"); %>
        </div>
      </c:if>

      <form action="hospital/add" method="post" class="form-container">
        <div class="form-group">
          <label for="hospitalname">医院名称：</label>
          <input type="text" id="hospitalname" name="hospitalname" value="${sessionScope.addHospital.hospitalname}" class="form-control" required>
        </div>
        <div class="form-group">
          <label for="address">地址：</label>
          <input type="text" id="address" name="address" value="${sessionScope.addHospital.address}" class="form-control" required>
        </div>
        <div class="form-group">
          <label for="hphone">联系电话：</label>
          <input type="text" id="hphone" name="hphone" value="${sessionScope.addHospital.hphone}" class="form-control" required>
        </div>
        <div class="form-actions">
          <a href="hospital/find" class="btn btn-default">取消</a>
          <button type="submit" class="btn btn-primary">保存</button>
        </div>
      </form>
    </div>
  </div>
</div>
<script>
  // 页面加载完成后清除session中的表单数据，避免下次打开页面时仍显示上次的数据
  window.onload = function() {
    <% session.removeAttribute("addHospital"); %>
  };
</script>
</body>
</html>